'''
Created on Jan 22, 2012

@author: yang
'''
import unittest
from google.appengine.ext import testbed
import model.setting as setting

class Test(unittest.TestCase):


    def setUp(self):
        #create an instance of the Testbed class.
        self.testbed = testbed.Testbed()
        self.testbed.activate();
        self.testbed.init_datastore_v3_stub()
        
        self.setting = setting.Setting(title = "yang",
                                    tags = ["123","234"],
                                    categories =["1","2"],
                                    key_name = "setting"                                
                                    )
        self.setting.put()
        

    def tearDown(self):
        self.testbed.deactivate()


    def testSetting(self):
        settings = self.setting.get_by_key_name("setting")
        self.assertEqual(1, len(setting.Setting.all().fetch(2)))
        self.assertEqual("yang",settings.title)
        self.assertEqual(["123","234"],settings.tags)
        self.assertEqual(["1","2"],settings.categories)


if __name__ == "__main__":
    unittest.main()
    
    
    
    
    
    